package com.haruhinav.service.impl;

import com.haruhinav.entity.EmailDetails;
import com.haruhinav.entity.YiBanRemindPunch;
import com.haruhinav.entity.vo.ResultVO;
import com.haruhinav.mapper.YiBanRemindPunchMapper;
import com.haruhinav.service.YiBanRemindPunchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class YiBanRemindPunchServiceImpl implements YiBanRemindPunchService {

    @Autowired
    YiBanRemindPunchMapper yiBanRemindPunchMapper;


    @Override
    public ResultVO getEmailDetails() {
        ResultVO res = new ResultVO();
        res.fill(0,"success","OK",yiBanRemindPunchMapper.getEmailDetails());
        return res;
    }

    @Override
    public ResultVO queryYiBanRemindPunch(YiBanRemindPunch yiBanRemindPunch) {
        ResultVO res = new ResultVO();
        res.fill(0,"success","OK",yiBanRemindPunchMapper.queryYiBanRemindPunch(yiBanRemindPunch));
        return res;
    }

    @Override
    public ResultVO updateEmailDetails(EmailDetails emailDetails) {
        ResultVO res = new ResultVO();
        if(yiBanRemindPunchMapper.updateEmailDetails(emailDetails)>0){
            res.fill(0,"success","更新成功",emailDetails);
            return res;
        }
        res.fill(-1,"error","更新失败");
        return res;
    }

    @Override
    public ResultVO addYiBanUser(YiBanRemindPunch yiBanRemindPunch) {
        ResultVO res = new ResultVO();
        int count = yiBanRemindPunchMapper.addYiBanUser(yiBanRemindPunch);
        if(count > 0 && yiBanRemindPunch.getId()!=0){
            res.fill(0,"success","添加成功",yiBanRemindPunch);
            return res;
        }
        res.fill(-1,"error","添加失败");
        return res;
    }

    @Override
    public ResultVO updateYiBanUser(YiBanRemindPunch yiBanRemindPunch) {
        ResultVO res = new ResultVO();
        if(yiBanRemindPunchMapper.updateYiBanUser(yiBanRemindPunch)>0){
            res.fill(0,"success","更新成功",yiBanRemindPunch);
            return res;
        }
        res.fill(-1,"error","更新失败");
        return res;
    }

    @Override
    public ResultVO removeYiBanUser(Integer id) {
        ResultVO res = new ResultVO();
        if(yiBanRemindPunchMapper.removeYiBanUser(id)>0){
            res.fill(0,"success","删除成功");
            return res;
        }
        res.fill(-1,"error","更新成功");
        return res;
    }

    @Override
    public ResultVO findUserById(int id) {
        ResultVO res = new ResultVO();
        res.fill(0,"success","OK",yiBanRemindPunchMapper.findUserById(id));
        return res;
    }
}
